package com.cfg.controller;

import com.cfg.domain.*;
import com.cfg.service.DmCustomstatsColService;
import com.cfg.service.DmCustomstatsService;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;

import com.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/cfgStatistics")
@Api(tags = "自定义报表")
public class CfgStatisticsController extends BaseController {

    @Autowired
    public DmCustomstatsService dmCustomstatsService;

    @Autowired
    public DmCustomstatsColService dmCustomstatsColService;

    @GetMapping("/getCustomstats")
    @ApiOperation(value = "自定义表头行")
    public AjaxResult getCustomstats()
    {
        List<DmCustomstats> cfgTreeSelects =dmCustomstatsService.buildDeptTreeSelect();
        return success(cfgTreeSelects);
    }

    @GetMapping("/getCustomstatscol")
    @ApiOperation(value = "自定义表头列")
    public AjaxResult getCustomstatscol(DmCustomstatsCol dmCustomstatsCol)
    {
        if(StringUtils.isEmpty(dmCustomstatsCol.getColumnTYPE()))
            return error("ColumnTYPE不能为空");
        List<DmCustomstatsCol> cfgTreeSelects =dmCustomstatsColService.buildDeptTreeSelect(dmCustomstatsCol);
        return success(cfgTreeSelects);
    }











}
